<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.fx.css3.Transition</title>
<script src="../../base.js"></script>
<script>
  goog.require('goog.dispose');
  goog.require('goog.dom');
  goog.require('goog.events');
  goog.require('goog.fx.css3.Transition');
  goog.require('goog.style.transition');
  goog.require('goog.testing.MockClock');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>

var transition;
var element;
var mockClock;


function createTransition(element, duration) {
  return new goog.fx.css3.Transition(
      element, duration, {'opacity': 0}, {'opacity': 1},
      {property: 'opacity', duration: duration, timing: 'ease-in', delay: 0});
}


function setUp() {
  element = goog.dom.createElement('div');
  document.body.appendChild(element);
}


function tearDown() {
  goog.dispose(transition);
  goog.dispose(mockClock);
  goog.dom.removeNode(element);
}


function testPlayEventFiredOnPlay() {
  transition = createTransition(element, 10);
  var handlerCalled = false;
  goog.events.listen(transition, goog.fx.Transition.EventType.PLAY,
      function() {
        handlerCalled = true;
      });

  transition.play();
  assertTrue(handlerCalled);
}


function testBeginEventFiredOnPlay() {
  transition = createTransition(element, 10);
  var handlerCalled = false;
  goog.events.listen(transition, goog.fx.Transition.EventType.BEGIN,
      function() {
        handlerCalled = true;
      });

  transition.play();
  assertTrue(handlerCalled);
}


function testEndEventFiredOnStop() {
  transition = createTransition(element, 10);
  var handlerCalled = false;
  goog.events.listen(transition, goog.fx.Transition.EventType.END,
      function() {
        handlerCalled = true;
      });

  transition.play();
  transition.stop();
  assertTrue(handlerCalled);
}


function testFinishEventFiredOnStop() {
  transition = createTransition(element, 10);
  var handlerCalled = false;
  goog.events.listen(transition, goog.fx.Transition.EventType.FINISH,
      function() {
        handlerCalled = true;
      });

  transition.play();
  transition.stop();
  assertTrue(handlerCalled);
}


function testStopEventFiredOnStop() {
  transition = createTransition(element, 10);
  var handlerCalled = false;
  goog.events.listen(transition, goog.fx.Transition.EventType.STOP,
      function() {
        handlerCalled = true;
      });

  transition.play();
  transition.stop();
  assertTrue(handlerCalled);
}

</script>
</body>
</html>
